<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>经营指标（项目）</title>
  <style type="text/css">
  </style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form">
        <!-- 数据表单 -->
        <div style="text-align: center; margin-bottom:18px;">
	          <div class="layui-inline" style=" margin-top:15px;">
	          	<span style="margin-top:15px;font-size:15px;letter-spacing:1px;font-weight:bold;">${stsMonth }-${orgName }-${targetName }</span>
          	  </div>
	          <div class="layui-inline" style="margin-top:8px;float:right;margin-bottom:2px;margin-right:0px;">
	         	<label class="layui-form-label">单位</label> 
         	 	<div class="layui-inline" style="width:70px;">
	         		<select id="money_unit_ctrl" class="layui-select" lay-filter="money_unit_ctrl">
			    		<option value='1'>元</option>
						<option value="2" selected>万元</option>
						<option value="3">亿元</option>
				  	</select>
			  	</div>
          	  </div>
        </div>
        <hr/>
        <table id="LAY-qa-console-manage" lay-filter="LAY-qa-console-manage"></table>
      </div>
    </div>
  </div>

  <script>
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table;
	    
		var colsInit = [
				 {type:'numbers', title: '序号',fixed:'left'}
				,{field: 'orgProName', title: '项目公司',fixed:'left',templet: function(d){
				  		return '<a href="javascript:void(0)" lay-event="targetView" style="text-decoration:underline;color:#009688;">'+d.orgProName+'</a>';
					}
				}
				,{field: 'curMonthPlan', title: '月度计划（元）',hide:true,templet: function(d){
					    return formatCurrency(d.curMonthPlan);
				}}
				,{field: 'curMonthPlanTts', title: '月度计划（万元）',templet: function(d){
					    return formatCurrency(d.curMonthPlanTts);
				}}
				,{field: 'curMonthPlanHms', title: '月度计划（亿元）',hide:true,templet: function(d){
					    return d.curMonthPlanHms;
				}}
				,{field: 'curMonthFinish', title: '月度完成（元）',hide:true,templet: function(d){
						if(d.curMonthFinish < d.curMonthPlan){
							return '<font color=red>'+formatCurrency(d.curMonthFinish)+'</font>';
						}else{
					    	return formatCurrency(d.curMonthFinish);
						}
				}}
				,{field: 'curMonthFinishTts', title: '月度完成（万元）',templet: function(d){
						if(d.curMonthFinish < d.curMonthPlan){
							return '<font color=red>'+formatCurrency(d.curMonthFinishTts)+'</font>';
						}else{
					    	return formatCurrency(d.curMonthFinishTts);
						}
				}}
				,{field: 'curMonthFinishHms', title: '月度完成（亿元）',hide:true,templet: function(d){
						if(d.curMonthFinish < d.curMonthPlan){
							return '<font color=red>'+formatCurrency(d.curMonthFinishHms)+'</font>';
						}else{
					    	return d.curMonthFinishHms;
						}
				}}
				,{field: 'curMonthRate', title: '月度完成率',templet: function(d){
						return d.curMonthRate + '%';
				}}
				,{field: 'yearAddupPlan', title: '月累计划（元）',hide:true,templet: function(d){
					    return formatCurrency(d.yearAddupPlan);
				}}
				,{field: 'yearAddupPlanTts', title: '月累计划（万元）',templet: function(d){
					    return formatCurrency(d.yearAddupPlanTts);
				}}
				,{field: 'yearAddupPlanHms', title: '月累计划（亿元）',hide:true,templet: function(d){
					    return d.yearAddupPlanHms;
				}}
				,{field: 'yearAddupFinish', title: '月累完成（元）',hide:true,templet: function(d){
					    return formatCurrency(d.yearAddupFinish);
				}}
				,{field: 'yearAddupFinishTts', title: '月累完成（万元）',templet: function(d){
					    return formatCurrency(d.yearAddupFinishTts);
				}}
				,{field: 'yearAddupFinishHms', title: '月累完成（亿元）',hide:true,templet: function(d){
					    return d.yearAddupFinishHms;
				}}
				,{field: 'yearAddupRate', title: '月累完成率',templet: function(d){
						return d.yearAddupRate + '%';
				}}
				,{field: 'yearAllPlan', title: '年度计划（元）',hide:true,templet: function(d){
					    return formatCurrency(d.yearAllPlan);
				}}
				,{field: 'yearAllPlanTts', title: '年度计划（万元）',templet: function(d){
					    return formatCurrency(d.yearAllPlanTts);
				}}
				,{field: 'yearAllPlanHms', title: '年度计划（亿元）',hide:true,templet: function(d){
					    return d.yearAllPlanHms;
				}}
				,{field: 'yearAllRate', title: '年度完成率',templet: function(d){
						return d.yearAllRate + '%';
				}}
	       ];
		
		/** 渲染判断  **/
		function customerCols(){
			var unit = $('#money_unit_ctrl').val();
			if(unit==1){
				// 元
				colsInit[2].hide = false;
				colsInit[5].hide = false;
				colsInit[9].hide = false;
				colsInit[12].hide = false;
				colsInit[16].hide = false;
				// 万元
				colsInit[3].hide = true;
				colsInit[6].hide = true;
				colsInit[10].hide = true;
				colsInit[13].hide = true;
				colsInit[17].hide = true;
				// 亿元
				colsInit[4].hide = true;
				colsInit[7].hide = true;
				colsInit[11].hide = true;
				colsInit[14].hide = true;
				colsInit[18].hide = true;
			}
			if(unit==2){
				// 元
				colsInit[2].hide = true;
				colsInit[5].hide = true;
				colsInit[9].hide = true;
				colsInit[12].hide = true;
				colsInit[16].hide = true;
				// 万元
				colsInit[3].hide = false;
				colsInit[6].hide = false;
				colsInit[10].hide = false;
				colsInit[13].hide = false;
				colsInit[17].hide = false;
				// 亿元
				colsInit[4].hide = true;
				colsInit[7].hide = true;
				colsInit[11].hide = true;
				colsInit[14].hide = true;
				colsInit[18].hide = true;
			}
			if(unit==3){
				// 元
				colsInit[2].hide = true;
				colsInit[5].hide = true;
				colsInit[9].hide = true;
				colsInit[12].hide = true;
				colsInit[16].hide = true;
				// 万元
				colsInit[3].hide = true;
				colsInit[6].hide = true;
				colsInit[10].hide = true;
				colsInit[13].hide = true;
				colsInit[17].hide = true;
				// 亿元
				colsInit[4].hide = false;
				colsInit[7].hide = false;
				colsInit[11].hide = false;
				colsInit[14].hide = false;
				colsInit[18].hide = false;
			}
		}
		// 切换单位时 重新渲染		
		form.on('select(money_unit_ctrl)', function(data){
			// 处理列显示
			customerCols();
			// 表单
	    	table.render({
	      		elem: '#LAY-qa-console-manage'
	      		,url: basePath + '/qaConsole/queryProTargetByCondition' //请求数据接口
	      		,where: {'stsMonth':'${stsMonth}','orgId':'${orgId}','aimType':'${aimType}'}
	      		,cols: [colsInit]
	      		,page: true
	      		,limit: 10
	    	});
    	});
		
    	// 表单
    	table.render({
      		elem: '#LAY-qa-console-manage'
      		,url: basePath + '/qaConsole/queryProTargetByCondition' //请求数据接口
      		,where: {'stsMonth':'${stsMonth}','orgId':'${orgId}','aimType':'${aimType}'}
      		,cols: [colsInit]
      		,page: true
      		,limit: 10
    	});
    	
    	// 监听操作列
    	table.on('tool(LAY-qa-console-manage)', function(obj){
      		var data = obj.data;
      		var proCode = data.proCode;
      		var aimType = data.aimType;
 			if(obj.event === 'targetView'){
	       		parent.layui.index.openTabsPage(basePath + '/qaConsole/qaProDetail?proCode='+proCode+'&aimType='+aimType,'${targetName}（项目信息）');
	   		}
    	});
  });
  	
  </script>
</body>
</html>

